﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;

namespace ZF.WS.UserControls.Index
{
    public partial class JPLP : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {
          
                List<object> list = null;

                var cacheKey = "_index_JPLP";
                var obj = HttpCache.GetCache(cacheKey);
                if (obj != null)
                {
                    list = obj as List<object>;
                }
                else
                {
                    list = dc.H_Estate.Where(p => p.IsVerify).Where(p => p.IsRecommend)
                     .OrderByDescending(p => p.EstateId).Take(20).ToList().Select(p => (object)p).ToList();
                    SiteInfo.Instance.SetPageCache(cacheKey,list);
                }

                if (list.Count < 20 && SiteInfo.Instance.IsLocal)
                    list.AddRange(list);

                this.lvJPLP.DataSource = list.Take(20);
                this.lvJPLP.DataBind();

            }


 



            using (var dc = SiteInfo.CreateDBDataContext())
            {

                List<object> list = null;

                var cacheKey = "_index_Blog";
                var obj = HttpCache.GetCache(cacheKey);
                if (obj != null)
                {
                    list = obj as List<object>;
                }
                else
                {
                    list = dc.Sys_SiteBlog 
                     .OrderByDescending(p => p.OrderId).Take(20).ToList().Select(p => (object)p).ToList();
                    SiteInfo.Instance.SetPageCache(cacheKey, list);
                }
           

                this.lvBlog.DataSource = list.Take(12);
                this.lvBlog.DataBind();

            }
        }
    }
}